import type {CEType, Viewer} from "vendor/components/pro-cesium";
import smallElecImgUrl from "./img/elec.png";

/**
 * 双图对比
 */
export const doubleContrast = (CE: CEType, viewer: Viewer) => {
    let key = '1c3ff1358b17417f1782dd1ae7bdd00a'
    let img = CE.ImageryLayerFactory.createTdtImageryLayer({
        key,
        style: 'img'
    })
    viewer.addBaseLayer(img)
    let baselayer_elc = CE.ImageryLayerFactory.createTdtImageryLayer({
        key
    })
    viewer.mapSplit.enable = true
    viewer.mapSplit.addBaseLayer(baselayer_elc)
}


/**
 * 地图滤镜
 */
export const mapFilter = (CE: CEType, viewer: Viewer) => {
    viewer.setOptions({
        globe:{
            filterColor:CE.Color.fromCssColorString("rgb(4,54,108)")
        }
    })
    let baselayer = CE.ImageryLayerFactory.createAmapImageryLayer()
    viewer.addBaseLayer(baselayer, {
        iconUrl: smallElecImgUrl,
        name: '电子'
    })
    viewer.zoomToPosition(
        new CE.Position(105.565571, 31.984708, 15362816, 0, -90)
    )
}

/**
 * 地形图
 */
export const mapTerrain = (CE: CEType, viewer: Viewer) => {
    let key = '1c3ff1358b17417f1782dd1ae7bdd00a'
    let baselayer = CE.ImageryLayerFactory.createTdtImageryLayer({
        key,
        style: 'img'
    })
    viewer.addBaseLayer(baselayer)
    let terrain = CE.TerrainFactory.createArcgisTerrain({
        url: 'https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer'
    })
    viewer.addTerrain(terrain)
    viewer.flyToPosition(
        new CE.Position(
            96.70456483909693,
            28.883444927447762,
            48977.26981733466,
            0,
            -32
        )
    )
}